package com.jflm.controller.exception;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * ******************  类说明  *********************
 * class       :  GlobalExceptionHandler
 * @author     :  hejinyun@umfintech.com
 * @version    :  1.0  
 * description :  平台统一异常处理
 * @see        :                        
 * ***********************************************
 */
@ControllerAdvice
public class GlobalExceptionHandler {

	private static final Logger LOG = LoggerFactory.getLogger(GlobalExceptionHandler.class);
	
	@ExceptionHandler(value=Exception.class)
	@ResponseBody
	public Object jsonErrorHandler(HttpServletRequest request, Exception e) throws Exception{
		LOG.error("#jsonErrorHandler() 访问URI===>{}异常", request.getRequestURI(), e);
		Map<String, String> ret = new HashMap<String, String>();
		ret.put("ret", "error");
		ret.put("msg", "系统异常["+e.getMessage()+"]");
		
		return ret;
	}
}
